//
//  FaceToFaceTableViewCell.m
//  SeaMelonSeeds_Counselor
//
//  Created by 尤振宇 on 2017/7/31.
//  Copyright © 2017年 杨笑. All rights reserved.
//

#import "FaceToFaceTableViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@implementation FaceToFaceTableViewCell
{
    Order *_order;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)refused:(id)sender {
    if (self.refuseBlock) {
        self.refuseBlock(sender);
    }
}

- (IBAction)accept:(id)sender {
    if (self.acceptBlock) {
        self.acceptBlock(sender);
    }
}

-(void)setOrder:(Order *)order
{
    _order = order;
    
    [self.headPortrait sd_setImageWithURL:[NSURL URLWithString:order.user_avatar] placeholderImage:[UIImage imageNamed:@"My_TheDefaultAvatar"]];
    self.title.text = [NSString stringWithFormat:@"%@  %d岁  %@",order.nickname,order.age,order.sex?@"女":@"男"];
    self.describe.object = order;
    
    NSMutableAttributedString *attString = [[NSMutableAttributedString alloc]initWithString:@"预约时间: " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    [attString appendAttributedString:[[NSAttributedString alloc] initWithString:order.serviced_at attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:k666666}]];
    self.time.attributedText = attString;
    
    NSMutableAttributedString *attString2 = [[NSMutableAttributedString alloc]initWithString:@"预约时间: " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blackColor]}];
    
    [attString2 appendAttributedString:[[NSAttributedString alloc] initWithString:order.created_at attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:k666666}]];
    self.createdTime.attributedText = attString2;
    
   
    if (order.is_timeout || order.refused_at) {
        if (order.refused_at) {
            self.timeout.text = @"已拒绝";
        }else{
            self.time.text = @"已超时";
        }
        self.refuse.hidden = YES;
        self.accept.hidden = YES;
        self.line.hidden = YES;
        
        self.timeout.hidden = NO;
    }else{
        self.refuse.hidden = NO;
        self.accept.hidden = NO;
        self.line.hidden = NO;
        
        self.timeout.hidden = YES;
    }
    
}


-(Order *)order
{
    return _order;
}

@end
